<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./style.css">
</head>
<body>
    <div class="range">
        <div class="slideValue">
            <span>100</span>
        </div>
        <div class="field">
            <div class="value left">0</div>
            <input type="range" min="0" max="200" value="100" steps="1">
            <div class="value right">200</div>
        </div>
    </div>


    <script>
        const slideValue = document.querySelector('span');
        const inputSlide = document.querySelector('input');
        inputSlide.oninput = ()=>{
            let value = inputSlide.value;
            slideValue.textContent = value;
            slideValue.style.left=value/2+'%';
            slideValue.classList.add('show');
        }


        // 当鼠标移入显示音量
        inputSlide.onmouseenter=()=>{
            slideValue.classList.add('show');
        }

        // 鼠标离开
        inputSlide.onmouseleave=()=>{
            slideValue.classList.remove('show');
        }
    </script>
</body>
</html>